*** Settings ***
Documentation               通过Redfish修改LogService的时区属性值
Resource                    ../../test_function/redfish/redfish.robot
Resource                    ../../test_function/resource.robot
Library                     RequestsLibrary
Library                     Collections
Library                     String
Suite Setup                 Create Redfish_PATCH Session
Suite Teardown              Delete All Sessions

*** Variables ***
${INPUT_URI}                /Systems/${SYSTEM_ID}/LogServices/Log1
${ETAG}                     ${EMPTY}

*** Test Cases ***
Modify LogServices DateTimeLocalOffset Interface
    [Documentation]    通过Redfish修改登录服务内容
    [Tags]    Modify_LogService_DateTimeLocalOffset_Interface
    # patch方法需要ETag
    Get User ETag

    # 搭建headers
    ${headers}=    Create Dictionary
    ...    Content-Type=application/json
    ...    X-Auth-Token=${AUTH_TOKEN}
    ...    If-Match=${ETAG}

    # 修改属性内容--{body}
    ${datetime}=    Set Variable    +08:00
    ${payload}=    Create Dictionary    DateTimeLocalOffset=${datetime}

    ${rsp}=    PATCH On Session    redfish_patch
    ...    ${INPUT_URI}
    ...    json=${payload}
    ...    headers=${headers}

    # 验证响应状态码
    Should Be Equal As Strings    ${rsp.status_code}    ${SUCCESS_CODE}
    ...    msg=修改请求失败, 状态码:${rsp.status_code}

    # 验证返回的datetimeoffset值
    ${expected_output}=    Set Variable    UTC+08:00
    Should Be Equal    ${rsp.json()["DateTimeLocalOffset"]}    ${expected_output}
    Log    LogServices中DateTimeLocalOffset的值为: ${rsp.json()["DateTimeLocalOffset"]}    level=INFO
